package com.streamkar.entity.request;

import com.streamkar.constant.Constants;
import com.streamkar.entity.base.RequestPaging;
import com.streamkar.entity.domain.Talent;
import org.apache.commons.lang3.StringUtils;

import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 * @ClassName TalentRequest
 * @Description
 * @Author tyfrost
 * @Date 2018/11/15 上午10:49
 * @Version 1.0
 */
public class TalentRequest extends RequestPaging {
    /**
     * 主播等级
     */
    private Integer talentLevel;
    /**
     * 主播状态
     */
    private Boolean left;

    /**
     * 代理ID
     */
    private Long agencyId;

    /**
     * 检索值
     */
    private String queryValue;

    public Talent toEvent() {
        Talent talent = null;
        try {
            talent = this.toEntity(Talent.class);
            // 开始时间为空，
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            if (StringUtils.isBlank(this.getStartTime())) {
                Calendar calendar = Calendar.getInstance();
                calendar.set(Calendar.YEAR, 2015);
                calendar.set(Calendar.MONTH, 1);
                calendar.set(Calendar.DAY_OF_MONTH, 1);
                talent.setStartTime(sdf.format(calendar.getTime()));
            }
            if (StringUtils.isBlank(this.getEndTime())) {
                Calendar calendar = Calendar.getInstance();
                calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
                talent.setEndTime(sdf.format(calendar.getTime()));
            }
            // 默认按钻石查询
            if ("1".equals(talent.getOrderBy())) {
                talent.setOrderBy(Constants.TALENT_SORTBY);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return talent;
    }

    public Integer getTalentLevel() {
        return talentLevel;
    }

    public void setTalentLevel(Integer talentLevel) {
        this.talentLevel = talentLevel;
    }

    public Boolean getLeft() {
        return left;
    }

    public void setLeft(Boolean left) {
        this.left = left;
    }

    public Long getAgencyId() {
        return agencyId;
    }

    public void setAgencyId(Long agencyId) {
        this.agencyId = agencyId;
    }

    public String getQueryValue() {
        return queryValue;
    }

    public void setQueryValue(String queryValue) {
        this.queryValue = queryValue;
    }
}
